package com.molyfun.parents.fragment.dialog;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import com.molyfun.parents.R;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class OrigiationApplySuccessFragment extends DialogFragment implements View.OnClickListener{

    @InjectView(R.id.notice)
    TextView mNotice;
    @InjectView(R.id.commit)
    TextView mCommit;

    private static OrigiationApplySuccessFragment newInstance() {
        OrigiationApplySuccessFragment mStudentMenuDialogFragment = new OrigiationApplySuccessFragment();
        return mStudentMenuDialogFragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setCancelable(false);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.dialog_origiation_apply_success, container, false);
        ButterKnife.inject(this, view);

        mNotice.setText(Html.fromHtml("&nbsp; &nbsp; 请耐心等待，1个工作日内会完成审核，<span style=\"color:#333333;font-family:&quot;font-size:14px;\">在此期间请保持注册手机号的畅通。审核</span><span style=\"color:#333333;font-family:&quot;font-size:14px;\">通过后会在软件“<span style=\"color:#E53333;\">消息</span>”中提醒。</span>"));
        mNotice.setOnClickListener(this);
        mCommit.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.cancel:
                getDialog().dismiss();
                break;
            case R.id.commit:
                getDialog().dismiss();
                break;
            default:
                break;
        }

    }

    public static class OrigiationApplySuccessDialogBuilder {

        OrigiationApplySuccessFragment mCommonDialogFragment;
        private String mTag;

        public OrigiationApplySuccessDialogBuilder(){
            mCommonDialogFragment = OrigiationApplySuccessFragment.newInstance();
            mTag = "origiation_apply_success";
        }
        public OrigiationApplySuccessDialogBuilder setTag(String tag){
            this.mTag = tag;
            return this;
        }

        public void build(FragmentTransaction fragmentTransaction){
            fragmentTransaction.add(mCommonDialogFragment, mTag);
            fragmentTransaction.commitAllowingStateLoss();
        }

    }
}
